package com.anytron.config;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.anytron.model.res.ResultData;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {

    @ResponseBody
    @ExceptionHandler(value = Exception.class)
    public ResultData<String> handle(Exception e) {
    	log.error(e.getMessage(),e);
    	ResultData<String> resultData = new ResultData<>();
    	resultData.setErrorCode(-1);
    	resultData.setSuccess(false);
    	resultData.setErrorMsg(e.getMessage());
		return resultData;
    }
}
